﻿using System;
using System.Drawing;
using Lottery.App;
using Lottery.App.BLL;
using System.Windows.Forms;

namespace UI
{
    public partial class TJ : Form
    {
        private GameMode _gm;
        private LotteryManager _manager = new LotteryManager();

        public TJ(GameMode gm)
            : this(gm, String.Empty)
        { 
        }

        public TJ(GameMode gm, string title)
        {
            InitializeComponent();

            this.Text = title;
            dgv_list.AutoGenerateColumns = false;
            _gm = gm;
        }

        private void TJ_Load(object sender, EventArgs e)
        {
            LoadData(OrderBy.ID);
        }

        public void LoadData(OrderBy order)
        {
            dgv_list.DataSource = _manager.List(_gm, order);

            dgv_list.Rows[0].Selected = false;
        }

        






        #region 列排序

        private void btnID_Click(object sender, EventArgs e)
        {
            LoadData(OrderBy.ID);

            ResetColumnColor(0);
        }

        private void btnOmit_Click(object sender, EventArgs e)
        {
            LoadData(OrderBy.CurrentOmit);

            ResetColumnColor(1);
        }

        private void btnMaxOmit_Click(object sender, EventArgs e)
        {
            LoadData(OrderBy.MaxOmit);

            ResetColumnColor(2);
        }

        private void btnDate_Click(object sender, EventArgs e)
        {
            LoadData(OrderBy.Date);

            ResetColumnColor(3);
        }

        private void btnTotalCount_Click(object sender, EventArgs e)
        {
            LoadData(OrderBy.TotalCount);

            ResetColumnColor(4);
        }


        private void ResetColumnColor(int column)
        {
            dgv_list.Columns[0].DefaultCellStyle.ForeColor = Color.Black;
            dgv_list.Columns[1].DefaultCellStyle.ForeColor = Color.Black;
            dgv_list.Columns[2].DefaultCellStyle.ForeColor = Color.Black;
            dgv_list.Columns[3].DefaultCellStyle.ForeColor = Color.Black;
            dgv_list.Columns[4].DefaultCellStyle.ForeColor = Color.Black;

            dgv_list.Columns[column].DefaultCellStyle.ForeColor = Color.Blue;
        }
        #endregion








    }
}
